{include file="common:lay_header" / }
{include file="common:upload" / }
<style>
    img#demo1 {
        width: 7%;
        margin-left: 107px;
    }
</style>
<body>
<form class="layui-form" action="" lay-filter="example">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">跳转链接</label>
        <div class="layui-input-block">
            <input type="text" name="click_url" lay-verify="required" autocomplete="off" placeholder="请输入跳转链接" class="layui-input">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">点击次数</label>
        <div class="layui-input-block">
            <input type="text" name="view" lay-verify="required" autocomplete="off" placeholder="请输入点击次数" class="layui-input"> *提示：请输入纯数字
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="sort" lay-verify="required" autocomplete="off" placeholder="请输入排序" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">评论数</label>
        <div class="layui-input-block">
            <input type="text" name="number" lay-verify="required" autocomplete="off" placeholder="请输入评论数" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">车系选择</label>
        <div class="layui-input-block">
            <select name="pid" lay-filter="aihao">
                <option value=""></option>
                {foreach $preat as $val}
                    <option value="{$val.id}">{$val.name}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">选择分类</label>
        <div class="layui-input-block">
            <select name="type" lay-filter="aihao">
                <option value=""></option>
                <option value="1">热门节目</option>
                <option value="2">高级私人订制</option>
                <option value="3">原创精选</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">创建时间</label>
        <div class="layui-input-block">
            <input type="text" name="create_time" lay-verify="required" autocomplete="off" placeholder="格式:2021-01-21 12:00:00" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">简介</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" name="desc"></textarea>
        </div>
    </div>

    <div class="layui-upload">
        <label class="layui-form-label">图片上传</label>
        <button type="button" class="layui-btn" id="test1">上传图片</button>
        <div class="layui-upload-list">
            <img class="layui-upload-img" id="demo1" width="20%">
            <p id="demoText"></p>
        </div>
        <input type="hidden" id="test2" name="image">
    </div>


    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>上传视频</legend>
    </fieldset>
    <div class="layui-form-item" id="videoUp">
        <label class="layui-form-label" style="height: 137px; line-height: 117px">视频</label>
        <input name="video" id="videourl"  value="" autocomplete="off" class="layui-input" type="hidden">
        <div class=" layui-upload-drag" id="video" style="border-left: 0px;" type="video">
            <i class="layui-icon">&#xe654;</i>
            <p>点击上传</p>
            <video id="demo9" src="" style="position: absolute;height: 137px;width: 137px;margin: -106px auto auto -60px;"/>
        </div>
        <input type="button" value="预览" onclick="openVideo()" style="margin-left: 30px">
    </div>





    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form>


<script src="__LAYUI__/layui.js" charset="utf-8"></script>

<script>
    layui.use(['upload','form','layedit'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,form = layui.form
            ,layedit = layui.layedit;


        //普通图片上传
        one_upload(upload,$);

        //上传视频
        upload_video(upload,$)


        //监听提交
        form.on('submit(demo1)', function(data){

            let json_field = data.field;
            console.log(json_field)
            let url = "{:url('create')}";

            let params = json_field;

           _axios(url,params);

            return false;
        });
    });
</script>

<script type="text/javascript">
    // 视频预览
    function openVideo() {
        video_view()
    }
</script>


</body>
</html>